package com.cola.custSpeechTranscription.config;

/**
 * @BelongsProject: speechTranscription
 * @BelongsPackage: com.example.demo.config
 * @CreateTime: 2025-06-29  14:47
 * @Description: TODO
 * @Version: 1.0
 */

import com.cola.custSpeechTranscription.api.CustAudioWebSocketHandler;
import com.cola.custSpeechTranscription.api.CustShareWebSocketHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

@Configuration
@EnableWebSocket
public class CustWebSocketConfig implements WebSocketConfigurer {

    @Autowired
    private CustAudioWebSocketHandler audioWebSocketHandler;

    @Autowired
    private CustShareWebSocketHandler shareWebSocketHandler;

    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(audioWebSocketHandler, "/rest/ws/custTranscribe")
                .setAllowedOrigins("*");

        registry.addHandler(shareWebSocketHandler, "/rest/ws/custShare/*")
                .setAllowedOrigins("*");

    }

}

